<template>
  <div style="color: #666;font-size: 14px;">
    <div style="padding-bottom: 20px">
      <b>欢迎你！{{ user.nickname }}</b>
    </div>
<!--    <el-card>-->
<!--      系统日志-->
<!--      <el-divider />-->
<!--      <el-carousel :interval="10000" type="card">-->
<!--        <el-carousel-item v-for="item in imgs" :key="item">-->
<!--          <img :src="item" style="width: 100%;border-radius: 10px">-->
<!--        </el-carousel-item>-->
<!--      </el-carousel>-->
<!--    </el-card>-->
    <div style="height: 1px; background: #ddd; margin: 20px 0"/>

    <el-row :gutter="30">
      <el-col :span="12">
        <div style="padding: 20px 0; font-size: 20px">近期流量统计</div>
        <div id="main" style="width: 500px; height: 400px"></div>
      </el-col>
      <el-col :span="12">
        <div style="padding: 20px 0; font-size: 20px">入驻品牌统计</div>
        <el-row>
          <div id="pie" style="width: 500px; height: 600px"></div>
        </el-row>
      </el-col>
    </el-row>

  </div>

</template>
<script>
import * as echarts from "echarts";

export default {
  name: "Home",
  data() {
    return {
      user: localStorage.getItem("user") ? JSON.parse(localStorage.getItem("user")) : {},
      imgs: [
        'https://s2.loli.net/2022/07/20/LGMc8n3m27iH1fl.png',
        'https://s2.loli.net/2022/07/20/TqNPgWMS7Kzv2dV.png',
        'https://s2.loli.net/2022/07/20/JzydANpuFrKsvOS.png',

      ]
    }
  },
  mounted() {
    var chartDom = document.getElementById('main');
    var myChart = echarts.init(chartDom);
    var option;

    option = {
      tooltip: {
        trigger: 'axis',
        axisPointer: {
          type: 'cross',
          label: {
            backgroundColor: '#6a7985'
          }
        }
      },
      legend: {
        data: ['Email', 'Union Ads', 'Video Ads', 'Direct', 'Search Engine']
      },
      toolbox: {
        feature: {
          saveAsImage: {}
        }
      },
      grid: {
        left: '3%',
        right: '4%',
        bottom: '3%',
        containLabel: true
      },
      xAxis: [
        {
          type: 'category',
          boundaryGap: false,
          data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
        }
      ],
      yAxis: [
        {
          type: 'value'
        }
      ],
      series: [
        {
          name: 'Email',
          type: 'line',
          stack: 'Total',
          areaStyle: {},
          emphasis: {
            focus: 'series'
          },
          data: [120, 132, 101, 134, 90, 230, 210]
        },
        {
          name: 'Union Ads',
          type: 'line',
          stack: 'Total',
          areaStyle: {},
          emphasis: {
            focus: 'series'
          },
          data: [220, 182, 191, 234, 290, 330, 310]
        },
        {
          name: 'Video Ads',
          type: 'line',
          stack: 'Total',
          areaStyle: {},
          emphasis: {
            focus: 'series'
          },
          data: [150, 232, 201, 154, 190, 330, 410]
        },
        {
          name: 'Direct',
          type: 'line',
          stack: 'Total',
          areaStyle: {},
          emphasis: {
            focus: 'series'
          },
          data: [320, 332, 301, 334, 390, 330, 320]
        },
        {
          name: 'Search Engine',
          type: 'line',
          stack: 'Total',
          label: {
            show: true,
            position: 'top'
          },
          areaStyle: {},
          emphasis: {
            focus: 'series'
          },
          data: [820, 932, 901, 934, 1290, 1330, 1320]
        }
      ]
    };

    myChart.setOption(option);


    var pieDom = document.getElementById('pie');
    var pieChart = echarts.init(pieDom);

    var pieOption = {
      tooltip: {
        trigger: 'item'
      },
      legend: {
        orient: 'vertical',
        left: 'left'
      },
      series: [
        {
          name: 'Access From',
          type: 'pie',
          radius: '50%',
          data: [
            { value: 800, name: 'XIAOMI' },
            { value: 600, name: 'Apple'},
            { value: 400, name: 'HUAWEI' },
            { value: 600, name: 'OPPO' },
            { value: 300, name: 'SAMSUNG' },
            { value: 200, name: 'GREE' },
            { value: 400, name: 'NIKE' },
          ],
          emphasis: {
            itemStyle: {
              shadowBlur: 10,
              shadowOffsetX: 0,
              shadowColor: 'rgba(0, 0, 0, 0.5)'
            }
          }
        }
      ]
    };
    pieChart.setOption(pieOption);

  }
}
</script>